<?php
include_once("./function.php");
//print_r($_GET);die;//Array ( [pid] => 28 )
extract($_GET);//$pid 
$pid=trim($pid);
//判断该商品是否有图片/图册
$sql="select new_img from ts_news where news_id='$pid'";
$res=mysqli_query($link,$sql);
if(is_object($res))
{
 $list=mysqli_fetch_assoc($res);
}
//print_r($list);die;//Array ( [new_img] => ./uploads/1307113087.jpg )
foreach($list as $v)
{
	 $v;//./uploads/1307113087.jpg
}
$more=explode(",",$v);
//print_r($more);die;//Array ( [0] => ./uploads/1307113087.jpg )
if($list['new_img']!='')
{
	for($i=0;$i<count($more);$i++)
	{
		unlink($more[$i]);
		//var_dump($m);
	}
}

//删除商品
if(isset($pid))
{
	$sql="delete from ts_news where news_id=$pid";
	$res=mysqli_query($link,$sql);
	//var_dump($res);die;
	if($res)
	{
		if(mysqli_affected_rows($link)==1)
		{//echo 5;die;
			msg("删除成功","product.php");exit;
		}
		else
		{
			msg("删除失败","product.php");exit;
		}
	}
}	
else
{
	echo "错误码:".mysqli_errno($link)."错误信息:".mysqli_error($link);exit;
}
	

?>